
var CanvasUtils = {
    createBuffer: function(w, h) {
        var buffer = document.createElement('canvas').getContext("2d");
        buffer.canvas.width = w;
        buffer.canvas.height = h;
        return buffer;
    }
    , getImageSector: function(img, x, y, w, h) {
        var buffer = CanvasUtils.createBuffer(w, h);
        buffer.drawImage(img, -1*x, -1*y);
        return buffer.canvas;
    }
}

var RandomUlils = {
    getRandomInt: function(min, max) {
        return Math.floor(Math.random() * (max - min + 1)) + min;
    },

    getRandomArbitary: function(min, max) {
        return Math.random() * (max - min) + min;
    }
}